<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods', function (Blueprint $table) {
            $table->increments('id')->comment('商品表');
            $table->string('name', 64)->default('')->comment('商品名称');
            $table->string('image', 255)->default('')->comment('图片名称');
			$table->unsignedInteger('quantity')->default(0)->comment('商品库存');
			$table->string('sku', 16)->default('')->comment('库存单位，如个|只|件');
			$table->string('upc', 191)->default('')->comment('通用商品代码');
			$table->decimal('price', 10, 2)->default(0.00)->comment('本店售价');
			$table->decimal('market_price', 10, 2)->default(0.00)->comment('市场价');
			$table->unsignedInteger('tax_id')->default(0)->comment('税类型');
			$table->unsignedTinyInteger('minimum')->default(1)->comment('最少起订数量');
			$table->unsignedTinyInteger('subtract')->default(0)->comment('是否减少库存');
			$table->unsignedInteger('stock_status_id')->default(0)->comment('库存状态id');
			$table->tinyInteger('shipping')->default(0)->comment('是否允许配送');
			$table->date('date_available')->comment('供货日期');
			$table->unsignedInteger('length')->default(0)->comment('商品长');
			$table->unsignedInteger('width')->default(0)->comment('商品宽');
			$table->unsignedInteger('height')->default(0)->comment('商品高');
			$table->unsignedInteger('length_unit_id')->default(0)->comment('长度单位');
			$table->unsignedInteger('weight')->default(0)->comment('商品重量');
	        $table->unsignedInteger('weight_unit_id')->default(0)->comment('重量单位');
	        $table->tinyInteger('status')->default(1)->comment('是否可用，默认可用1');
	        $table->tinyInteger('sort_number')->default(0)->comment('排序');
	        $table->text('description')->comment('商品描述');
	        $table->string('meta_title', 255)->default('')->comment('seo标题');
	        $table->string('meta_keyword', 255)->default('')->comment('seo关键词');
	        $table->string('meta_description', 255)->default('')->comment('seo描述');
	        $table->unsignedInteger('brand_id')->default(0)->comment('商品品牌id');
	        $table->unsignedInteger('category_id')->default(0)->comment('分类id');
	        $table->unsignedTinyInteger('delete')->default(0)->comment('是否被删除，逻辑删除允许还原');
            $table->timestamps();
            $table->index('brand_id');
            $table->index('category_id');
            $table->index('tax_id');
            $table->index('length_unit_id');
            $table->index('weight_unit_id');
            $table->index('stock_status_id');
            $table->index('sort_number');
            $table->index('price');
            $table->unique('upc');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods');
    }
}
